package cn.school.attendance.dormitory.dao;

import cn.school.attendance.dormitory.entity.DormitoryStatusDo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.*;

/**
 * @className: DormitoryStatusMapper
 * @author: Alex
 * @date: 2023/4/6
 **/
@Mapper
public interface DormitoryStatusMapper extends BaseMapper<DormitoryStatusDo> {

	@Select("select * from t_base_space_location tbs " +
			"LEFT JOIN (select location_id, count(id) as pCount from t_dormitory_berth tdb where tdb.use_student_id is not NULL GROUP BY tdb.location_id) as tcount ON tbs.id = tcount.location_id " +
			"where ${ew.sqlSegment}")
	@Results({
			@Result(column = "id", property = "id"),
			@Result(column = "pCount", property = "dormitoryCount")
	}
	)
	IPage<DormitoryStatusDo> getList(@Param("ew") LambdaQueryWrapper queryWrapper, @Param("page") IPage<DormitoryStatusDo> iPage);
	
}
